import request from '@/utils/request.js'

// =============== 题库 ==================
// 新增
export function addQuestion(data) {
  return request({
    url: '/question/addQuestion/',
    method: 'post',
    data
  })
}

// 删除
export function deleteQuestionByIds(ids) {
  return request({
    url: '/question/deleteQuestion/',
    method: 'post',
    data: { ids }
  })
}

// 修改
export function updateQuestionById(data) {
  return request({
    url: '/question/updateQuestion/',
    method: 'post',
    data
  })
}

// 查询全部 - 后期优化分页
export function getAllQuestionList() {
  return request({
    url: '/question/queryAllQuestion/',
    method: 'get'
  })
}

// 获取随机题目
export function getQuestionById(id) {
  return request({
    url: '/question/getQuestion/?id=' + id,
    method: 'get'
  })
}


// ================== 用户 ================
// 新增
export function addAccount(data) {
  return request({
    url: '/account/add/',
    method: 'post',
    data
  })
}

// 删除
export function deleteAccountByIds(data) {
  return request({
    url: '/account/delete/',
    method: 'post',
    data
  })
}

// 修改
export function updateAccountById(data) {
  return request({
    url: '/account/update/',
    method: 'post',
    data
  })
}

// 查询用户信息
export function getAccountById(id) {
  return request({
    url: '/account/queryUserInfo/?id=' + id,
    method: 'get'
  })
}

// 查询全部
export function getAllAccountList() {
  return request({
    url: '/account/queryAll/',
    method: 'get'
  })
}


// =========== 元素 =========================
export function queryAllElementList() {
  return request({
    url: '/element/queryAllElement/',
    method: 'get'
  })
}

export function getElementById(id) {
  return request({
    url: '/element/queryElement/?id=' + id,
    method: 'get'
  })
}

export function addElement(data) {
  return request({
    url: '/element/addElement/',
    method: 'post',
    data
  })
}

export function updateElementById(data) {
  return request({
    url: '/element/updateElement/',
    method: 'post',
    data
  })
}

export function deleteElementByIds(data) {
  return request({
    url: '/element/deleteElement/',
    method: 'post',
    data
  })
}

// ================= 食材 =====================
export function queryAllIngredientList() {
  return request({
    url: '/ingredients/queryAll/',
    method: 'get'
  })
}

export function getIngredientById(id) {
  return request({
    url: '/ingredients/queryById/?id=' + id,
    method: 'get'
  })
}

export function addIngredient(data) {
  return request({
    url: '/ingredients/add/',
    method: 'post',
    data
  })
}

export function updateIngredientById(data) {
  return request({
    url: '/ingredients/update/',
    method: 'post',
    data
  })
}

export function deleteIngredientByIds(data) {
  return request({
    url: '/ingredients/delete/',
    method: 'post',
    data
  })
}


// ================= 菜谱 =====================
export function queryAllFoodList() {
  return request({
    url: '/food/queryAll/',
    method: 'get'
  })
}

export function getFoodById(id) {
  return request({
    url: '/food/queryById/?id=' + id,
    method: 'get'
  })
}

export function addFood(data) {
  return request({
    url: '/food/add/',
    method: 'post',
    data
  })
}

export function updateFoodById(data) {
  return request({
    url: '/food/update/',
    method: 'post',
    data
  })
}

export function deleteFoodByIds(data) {
  return request({
    url: '/food/delete/',
    method: 'post',
    data
  })
}


// 共用

export function uploadImage(data) {
  return request({
    url: '/public/uploadImage',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
